package leetcode;

import java.util.Scanner;

public class Day33 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int[] A=new int[n];
        int[] B=new int[n];
        for (int i:A){
            A[i]=scanner.nextInt();
        }
        for (int i:B){
            B[i]=scanner.nextInt();
        }
        int min=Integer.MAX_VALUE;
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                if(i!=j){
                    int cur=Math.max(A[i],B[j]);
                    min=Math.min(min,cur);
                }
            }
            int cur2=A[i]+B[i];
            min=Math.min(min,cur2);
        }
        System.out.println(min);
    }
}
